#ifndef BuddyChat_H
#define BuddyChat_H
#include <QListWidgetItem>
#include <QDialog>
#include <QWidget>
#include "qclickedlabel.h"
#include <map>
#include <string>
using namespace std;
typedef struct _ChatObj
{
    uint type;
    uint number;
    QWidget* widget;
} ChatObj;
typedef map<string,ChatObj*> QQbuddyMap;
namespace Ui {
    class BuddyChat;
}

class BuddyChat : public QDialog {
    Q_OBJECT
public:
    BuddyChat(QWidget *parent = 0);
    ~BuddyChat();
    void ActiveTabByUid(uint number,QString nickName,uint type); /*0,buddy,1,qun*/
    bool UidIsTalking(uint uid,uint type);
    void EmitMSG();
protected:
    void changeEvent(QEvent *e);
public slots:
    void buddyTabCloseRequested(int index);
    void currentChanged(int index);
    void btn_sendClick(QClickedLabel*);
    void OnProcessMsg();
    void OnFastReplay(QListWidgetItem *item);
    void toogleDisplayFastReplayPanel();
    void toogleDisplayEmotePanel();
    void toogleBuddyInfoPanel();
    void OnEmoteClick(const QModelIndex &index);
    void OnCloseClicked();
signals:
    void NewMsgReached();

private:
    Ui::BuddyChat *ui;
    QClickedLabel* btnSend;
    QClickedLabel* btnReturn;
    QClickedLabel* btnEmote;
    QClickedLabel* btnPreMSG;
    QClickedLabel* btnBuddyInfo;
    void GetMemberNickName(uint type,uint number,uint qun_number,char* nickName);
    void loadRecordFromDB(uint uid,uint type);
    void Talk(QString &planInfo,QString &htmlInfo);
    void changeBG(uint type);
    void initEmoteList();
private:
    QQbuddyMap m_QQbuddy;
    uint getUIDbyWidget(QWidget* widget);
    uint getTYPEByWidget(QWidget* widget);
    ChatObj* getChatObjByWidget(QWidget* widget);
    uint m_type;
    int currentTabIndex;
};
extern BuddyChat* buddychatWin;
#endif // BuddyChat_H
